package com.youshang.controller;


import com.youshang.annotation.AccessLimit;
import com.youshang.config.ThreadPoolConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/home")
@RestController
public class ThreadControllerTest {

    @Autowired
    private ThreadPoolConfig poolConfig;

    @GetMapping("/thread")
    public String thread(@RequestParam(required = false) String student) {
        System.out.println("调用方法成功。。。。。。");
        try {
            Thread.sleep(5000);
            System.out.println("....延迟执行结果。。。。");
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
//        poolConfig.taskThreadPool().execute(() -> {
//            try {
//                Thread.sleep(2000);
//                System.out.println("....延迟执行结果。。。。");
//            } catch (InterruptedException e) {
//                throw new RuntimeException(e);
//            }
//        });
        System.out.println("执行成功。。。。。。");
        return "SUCCESS";
    }
}
